package com.iflytek.crvoice2txt.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.iflytek.crvoice2txt.util.DateUtil;

import java.util.Date;

import io.realm.RealmModel;
import io.realm.RealmObject;
import io.realm.annotations.Ignore;
import io.realm.annotations.RealmClass;
import io.realm.annotations.Required;

/**
 * 会议记录bean
 */

@RealmClass
public class RecorderEntity extends RealmObject implements RealmModel, Parcelable {

    /**
     * 1已修改，0未修改
     */
    @Required
    public Integer type;

    public Date date;

    public String name;

    public long size;

    public String txt_path;

    public String audio_path;

    public String dateStr;

    public Integer timelong;

    @Ignore
    public boolean isCurrent;

    @Ignore
    public String text;

    public RecorderEntity() {
    }

    public RecorderEntity(int type, Date date, String name, long size, String txt_path, String audio_path, String dateStr, Integer timelong, String text) {
        this.type = type;
        this.date = date;
        this.name = name;
        this.size = size;
        this.txt_path = txt_path;
        this.audio_path = audio_path;
        this.dateStr = dateStr;
        this.timelong = timelong;
        this.text = text;
    }

    protected RecorderEntity(Parcel in) {
        type = in.readInt();
        date = DateUtil.StrToDate(in.readString(), DateUtil.DF_YYYY_MM_DD_HH_MM_SS);
        name = in.readString();
        size = in.readLong();
        txt_path = in.readString();
        audio_path = in.readString();
        text = in.readString();
        dateStr = in.readString();
        timelong = in.readInt();
    }

    public static final Creator<RecorderEntity> CREATOR = new Creator<RecorderEntity>() {
        @Override
        public RecorderEntity createFromParcel(Parcel in) {
            return new RecorderEntity(in);
        }

        @Override
        public RecorderEntity[] newArray(int size) {
            return new RecorderEntity[size];
        }
    };

    @Override
    public String toString() {
        return "RecorderEntity{" +
                "type=" + type +
                ", date=" + date +
                ", name='" + name + '\'' +
                ", size=" + size +
                ", txt_path='" + txt_path + '\'' +
                ", audio_path='" + audio_path + '\'' +
                ", dateStr='" + dateStr + '\'' +
                ", timelong=" + timelong +
                ", text='" + text + '\'' +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(type);
        dest.writeString(DateUtil.DateToStr(date, DateUtil.DF_YYYY_MM_DD_HH_MM_SS));
        dest.writeString(name);
        dest.writeLong(size);
        dest.writeString(txt_path);
        dest.writeString(audio_path);
        dest.writeString(dateStr);
        dest.writeInt(timelong);
    }
}
